#!/usr/bin/env bash

__foe2head_stl0_FLOW() {

    if ! command -v foe2head_stl0 >/dev/null; then
        echo "TYPE_ERROR : foe2head_stl0" >&2
        return 1
    fi

    filename=${ST_RC_D_PATH}/.d/.arb/stl0.arb/foe2head_stl0.ram/.grot/_tst/_flow_tst.sh.v1

    local PW=$(pwd)
    local idir="$(dirname ${filename})"

    local ARGS0="$1"
    local ARGS1="$2"
    local ARGS2="$3"
    local ARGS3="$4"

    local NARGS=$#

    cd "${idir}" || {
        echo "${idir} not dir" >&2
        return 1
    }

    #?----------------------------------------------------
    #?-------------------------------------

    rm -rf ${HOME}/.foe.bac
    cp -r ${HOME}/.foe/init/. ${HOME}/.foe.bac
    : >${HOME}/.foe.bac/1.file
    echo "rbdbgf" >${HOME}/.foe.bac/init
    mkdir ${HOME}/.foe.bac/dir
    echo "yuoy" >${HOME}/.foe.bac/dir/2.file

    echo -e "${HLIGHT}--- foe2head_stl0 ${HOME}/.foe.bac ---${NORMAL}" #start files
    foe2head_stl0 ${HOME}/.foe.bac
    # _ret2e foe2head_stl0 ${HOME}/.foe.bac

    echo -e "${HLIGHT}--- foe2head_stl0 ${HOME}/x/.foe.bac ---${NORMAL}" #start files
    foe2head_stl0 ${HOME}/x/.foe.bac
    # _ret2e foe2head_stl0 ${HOME}/x/.foe.bac

    echo -e "${HLIGHT}--- cd ${HOME}/.foe.bac ---${NORMAL}" #start files
    cd ${HOME}/.foe.bac || {
        _st_exit "FAIL: cd ${HOME}/.foe.bac"
        return 1
    }

    echo -e "${HLIGHT}--- foe2head_stl0 ---${NORMAL}" #start files
    foe2head_stl0
    # _ret2e foe2head_stl0

    echo -e "${HLIGHT}--- foe2head_stl0 dfv ---${NORMAL}" #start files
    foe2head_stl0 dfv
    # _ret2e foe2head_stl0 dfv

    echo -e "${HLIGHT}--- foe2head_stl0 ${HOME}/.foe ---${NORMAL}" #start files
    foe2head_stl0 ${HOME}/.foe
    # _ret2e foe2head_stl0 ${HOME}/.foe

    echo -e "${HLIGHT}--- cat ${HOME}/.foe.bac/init ---${NORMAL}" #start files
    cat ${HOME}/.foe.bac/init
    file ${HOME}/.foe.bac/1.file
    file ${HOME}/.foe.bac/dir
    file ${HOME}/.foe.bac/dir/2.file

    # : >res

    #?-------------------------------------
    #?----------------------------------------------------

    cd "${PW}" || {
        echo "${PW} not dir" >&2
        return 1
    }

}

__foe2head_stl0_FLOW "$@"
